
#include "Attack.h"

#include "Character.h"
#include "Player.h"
#include "PlayerStats.h"
#include "Monster.h"
#include "MonsterStats.h"
#include <iostream>

using namespace std;

int main()
{
	PlayerStats pStats(5, 5, 7, 3, 100, 100, 1, 100, 100);
	Player p("tom the barbarian", WARRIOR, pStats);

	cout << "player level: " << p.getPlayerStats().getLevel() << endl;
	cout << "player damage before equip = " << p.getPlayerStats().getDamage() << endl;
	cout << "player armor before equip = " << p.getPlayerStats().getArmor() << endl;

	EquipmentType head(HEAD);
	EquipmentType chest(CHEST);
	EquipmentType gloves(GLOVES);
	EquipmentType feet(FEET);
	EquipmentType pants(PANTS);
	EquipmentType sword(WEAPON);
	
	string error;
	p.equip( &head  ,error );
	p.equip( &chest ,error );
	p.equip( &gloves,error );
	p.equip( &feet  ,error );
	p.equip( &pants ,error );
	p.equip( &sword ,error );

	cout << "player damage after equip = " << p.getPlayerStats().getDamage() << endl;
	cout << "player armor after equip = " << p.getPlayerStats().getArmor() << endl;
	
	Monster m(p.getPlayerStats().getLevel());
	
	cout << endl;
	
	// combat loop
	while( true )
	{
	
		// player attacks the monster
		cout << "monster level: " << m.getMonsterStats().getLevel() << endl;
		cout << "monster hitpoints before attack = " << m.getMonsterStats().getHitPoints() << endl;
		Attack::attack(&p, &m, 0);
		cout << "monster hitpoints after attack = " << m.getMonsterStats().getHitPoints() << endl;
	
		if( m.isDead() )
		{
			cout << "monster died!" << endl; 
			break;
		}
		
		
		// monster attacks the player
		cout << "player hitpoints before = " << p.getPlayerStats().getHitPoints() << endl;
		Attack::attack(&m, &p);
		cout << "player hitpoints after = " << p.getPlayerStats().getHitPoints() << endl;		
		
		if( p.isDead() )
		{
			cout << "player died!" << endl; 
			break;
		}		
	}	
	cout << endl;
	
	vector<AttackType> attacks = p.getAttacks();
	// current player stats
	cout << "Player current experience: " << p.getPlayerStats().getExp() << endl;
	cout << "Player current level: " << p.getPlayerStats().getLevel() << endl;
	cout << "Player strength: " << p.getPlayerStats().getStrength() << endl;
	cout << "Player agility: " << p.getPlayerStats().getAgility() << endl;
	cout << "Player intelligence: " << p.getPlayerStats().getIntelligence() << endl;
	cout << "Player concentration: " << p.getPlayerStats().getConcentration() << endl;
	cout << "Player num attacks: " << p.getNumAttacks() << endl;
	for(int i = 0; i < attacks.size(); i++){
		cout << attacks[i].getDesc() << endl;
	}
	bool unlocked = p.increaseExp(100);

	attacks = p.getAttacks();
	// player stats after increasing experience
	// should see level and num attacks increase
	cout << "\nPlayer current experience: " << p.getPlayerStats().getExp() << endl;
	cout << "Player current level: " << p.getPlayerStats().getLevel() << endl;
	cout << "Player strength: " << p.getPlayerStats().getStrength() << endl;
	cout << "Player agility: " << p.getPlayerStats().getAgility() << endl;
	cout << "Player intelligence: " << p.getPlayerStats().getIntelligence() << endl;
	cout << "Player concentration: " << p.getPlayerStats().getConcentration() << endl;
	cout << "Player num attacks: " << p.getNumAttacks() << endl;
	if(unlocked){
		cout << "unlocked new attack\n";
	}
	
	for(int i = 0; i < attacks.size(); i++){
		cout << attacks[i].getDesc() << endl;
	}
	
	cout << "\n\nplayer hitpoints before regenerate = " << p.getPlayerStats().getHitPoints() << endl;
	p.regenerateHP();
	cout << "player hitpoints after = " << p.getPlayerStats().getHitPoints() << endl;		

	cout << "\n\nplayer actionpoints before regenerate = " << p.getPlayerStats().getActionPoints() << endl;
	p.regenerateAP();
	cout << "player actionpoints after = " << p.getPlayerStats().getActionPoints() << endl;		
	return 0;
}
